package org.minos.edit.view.components
{
	import org.aswing.BorderLayout;
	import org.aswing.JMenu;
	import org.aswing.JMenuBar;
	import org.aswing.JMenuItem;
	import org.aswing.JPanel;
	import org.aswing.KeySequence;
	import org.aswing.KeyStroke;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class Menu extends JPanel
	{
		private var bar : JMenuBar
		
		private var fileMenu : JMenu;
		private var newMenu:JMenuItem;
		private var openMenu : JMenuItem;
		private var saveMenu : JMenuItem;
		private var exitMenu:JMenuItem;
		
		private var editMenu : JMenu;
		private var addTaskMenu : JMenuItem;
		private var editTaskMenu : JMenuItem;
		private var removeTaskMenu : JMenuItem;
		
		private var helpMenu : JMenu;
		private var aboutMenu : JMenuItem;
		
		public function Menu()
		{
			super();
			setLayout( new BorderLayout( 5 , 5) );
			setOpaque( true );
			
			bar = new JMenuBar();
			//file
			fileMenu = new JMenu( "文件(&F)" );
			newMenu = new JMenuItem( "新建(&N)");
			openMenu = new JMenuItem( "打开(&O)" );
			saveMenu = new JMenuItem( "保存(&S)" );
			exitMenu = new JMenuItem( "退出" );
			
			fileMenu.append( newMenu );
			fileMenu.append( openMenu );
			fileMenu.append( saveMenu );
			fileMenu.append( exitMenu );
			
			//edit
			editMenu = new JMenu( "编辑(&E)" );
			addTaskMenu = new JMenuItem( "添加(&A)" );
			editTaskMenu = new JMenuItem( "编辑(&E)" );
			removeTaskMenu = new JMenuItem( "删除(&D)" );
			editMenu.append( addTaskMenu );
			editMenu.append( editTaskMenu );
			editMenu.append( removeTaskMenu );
			//help
			helpMenu = new JMenu( "帮助(&H)" );
			aboutMenu = new JMenuItem( "关于(&A)" );
			helpMenu.append( aboutMenu );
			
			bar.appendAll( fileMenu , helpMenu );
			append( bar , BorderLayout.CENTER );
			
			//listeners
			//addTaskMenu.setAccelerator( new KeySequence( KeyStroke.VK_SHIFT , KeyStroke.VK_Q ) );
			//editTaskMenu.setAccelerator( new KeySequence( KeyStroke.VK_SHIFT , KeyStroke.VK_E ) );
			//removeTaskMenu.setAccelerator( new KeySequence( KeyStroke.VK_SHIFT , KeyStroke.VK_W ) );
			//openMenu.setAccelerator( new KeySequence( KeyStroke.VK_SHIFT , KeyStroke.VK_O ) );
			//saveMenu.setAccelerator( new KeySequence( KeyStroke.VK_SHIFT , KeyStroke.VK_S ) );
		}
		
		// ----- getter ----- //
		
		public function getRemoveMenu() : JMenuItem
		{
			return removeTaskMenu;
		}
		
		public function getEditMenu() : JMenuItem
		{
			return editTaskMenu;
		}
		
		public function getAddMenu() : JMenuItem
		{
			return addTaskMenu;
		}
		
		public function getOpenMenu() : JMenuItem
		{
			return openMenu;
		}
		
		public function getSaveMenu() : JMenuItem
		{
			return saveMenu;
		}
		
		public function getNewMenu():JMenuItem
		{
			return newMenu;
		}
	
	}

}